﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.WebPages;

namespace Bootstrap.MVC.Widgets
{
    public abstract class ModelBase : IModelBase
    {
        private Dictionary<string, object> attributes;
        public Dictionary<string, object> Attributes
        {
            get { return attributes; }
        }

        //public string Name { get; set; }

        //public string Id { get; set; }

        //public int Height { get; set; }

        //public int Withd { get; set; }

        public string Text { get; set; }

        
        public ViewContext ViewContext { get; set; }

        public Func<dynamic, HelperResult> Template;

      
        protected ModelBase(ViewContext context)
        {
            attributes = new Dictionary<string, object>();
            ViewContext = context;
        }

        protected ModelBase()
        {
            attributes = new Dictionary<string, object>();
        }

        public Dictionary<string, object> Attr()
        {
            return attributes;
        }

        public object Attr(string key)
        {
            object value;
            return  attributes.TryGetValue(key, out value) ? value: null; 
        }

        public void Attr(string key, object value)
        {
            attributes.Add(key, value);
        }

        public bool Disabled { set; get; }
    }


    public interface  IModelBase
    {
        Dictionary<string, object> Attributes { get; }
        //public string Name { get; set; }

        //public string Id { get; set; }

        //public int Height { get; set; }

        //public int Withd { get; set; } 
        
        //Func<dynamic, HelperResult> Template { get; set; }

        string Text { get; set; }

        ViewContext ViewContext { get; set; }

        Dictionary<string, object> Attr();

        object Attr(string key);

        void Attr(string key, object value);

        bool Disabled { set; get; }
    }
}
